#include <nice2d/components/fontmanager.h>

std::shared_ptr<sf::Font> FontManager::loadFromFile(const std::string &file)
{
    auto itr = resources.find(file);
    if (itr != resources.end())
        return itr->second;

    auto resource = std::make_shared<sf::Font>();
    if (!resource->loadFromFile(file))
        return nullptr;

    resources.insert(std::make_pair(file, resource));
    return resource;
}

void FontManager::removeResource(const std::string &name)
{
    resources.erase(name);
}
